package service

import (
	"work/src/work/global"
	"work/src/work/internal/dto"
	"work/src/work/internal/model"
)

type PlayVideoImpl interface {
	PlayVideo() []*dto.VideoReq
}
type PlayVideoMax struct {
}

func NewPlayVideoMax() *PlayVideoMax {
	return &PlayVideoMax{}
}
func (p *PlayVideoMax) PlayVideo() []*dto.VideoReq {

	var video []model.Video

	global.DB.Model(&model.Video{}).Limit(6).Order("play_quantity desc").Find(&video)

	var msg []*dto.VideoReq
	for _, m := range video {
		msg = append(msg, &dto.VideoReq{
			Name:         m.Name,
			PlayQuantity: m.PlayQuantity,
		})
	}

	return msg
}
